//添加
function  save() {
    var params = {};
    params['username']=$("#userName").val();
    params['password']=$("#userPwd").val();
    params['email']=$("#userEmail").val();

    jQuery.post('/empSave',params,function (res) {
        console.log(res);
        if (res.hasOwnProperty("msg1")){
                alert("用户名已存在！再想一个好名字吧...");
        }else if (res.hasOwnProperty("msg2")){
            alert("请完善信息....");
        } else {
                console.log(params);
                jQuery.post('/empSave',params,function (res) {
                    console.log(res);
                    $("#addEmp").modal('hide');
                    window.location.reload();
                },"json");
        }

    },"json");

}
//删除
function deleteEmp(id) {
    console.log(id);
    var params = {};
    params['id']=id;
    $.post('/empDelete',params,function (res) {
        window.location.reload();
    },"json");
}

//编辑
function editEmp(emp) {
    console.log(emp);
    $("#userId1").val(emp.id);
    $("#userName1").val(emp.username);
    $("#userPwd1").val(emp.password);
    $("#userEmail1").val(emp.email);

    $("#updateEmp").modal('show');
}

function  save1() {
    var params = {};
    params['id']=$("#userId1").val();
    params['username']=$("#userName1").val();
    params['password']=$("#userPwd1").val();
    params['email']=$("#userEmail1").val();

    jQuery.post('/empUpdate',params,function (res) {
        console.log(res);
        if (res.hasOwnProperty("msg2")){
            alert("请完善信息....");
        } else {
            console.log(params);
            jQuery.post('/empUpdate',params,function (res) {
                console.log(res);
                $("#updateEmp").modal('hide');
                window.location.reload();
            },"json");
        }

    },"json");
}